Learn R Programming

bnlearn (version 2.8)

node ordering utilities: Utilities dealing with partial node orderings

Description

Find the partial node ordering implied by a network or generate the blacklist implied by a complete node ordering.

Usage

node.ordering(x, debug = FALSE)
ordering2blacklist(nodes)

Arguments

x
an object of class bn or bn.fit.
nodes
a vector of character strings, the labels of the nodes. The ordering of the labels must reflect the partial node ordering of the nodes in the graph. Objects of class bn or bn.fit are also accepted, and the partial ord
debug
a boolean value. If TRUE a lot of debugging output is printed; otherwise the function is completely silent.

Value

  • node.ordering return a vector of character strings, an ordered set of node labels.

    ordering2blacklist returns a sanitized blacklist (a two-column matrix, whose columns are labeled from and to).

Examples

Run this code
data(learning.test)
res = gs(learning.test, optimized = TRUE)
res$learning$ntests
# [1] 43
res = set.arc(res, "A", "B")
ord = node.ordering(res)
ord
# [1] "A" "C" "F" "B" "D" "E"

## partial node ordering saves us two tests in the v-structure
## detection step of the algorithm.
gs(learning.test, blacklist = ordering2blacklist(ord))$learning$ntests
# [1] 41

Run the code above in your browser using DataLab